var arr = [];
for(var i=20 ; i<=2000 ; i++){
  arr.push({"name": "zhang" + i, "age": i+18});
}

db.user.insertMany(arr)


// 创建超级管理员权限
db.createUser(
  {
    user: "admin",
    pwd: "123456",
    roles: [ { role: "root", db: "admin"} ]
  }
)

// 对单个数据库设置admin权限
db.createUser(
  {
    user: "itying",
    pwd: "123456",
    roles: [ { role: "dbOwner", db: "itying"} ]
  }
)

// 管道使用
db.order.aggregate([
  {
    $project:{ trade_no:1, all_price:1 }
  },
  {
    $match:{"all_price":{$gte:90}}
  }
])

db.order.aggregate([
  {
    $lookup:
      {
        from: "order_item",
        localField: "order_id",
        foreignField: "order_id",
        as: "items"
      }
  }
])

db.order_item.insert({"order_id":"1","title":"摄像头","price":80,num:1})